package com.whj.apidriver.controller;

import com.whj.apidriver.service.UserService;
import com.whj.internalcommon.dto.DriverCarBindingRelationship;
import com.whj.internalcommon.dto.DriverUser;
import com.whj.internalcommon.dto.DriverUserWorkStatus;
import com.whj.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: wanghaijun
 * @Date: 2023/1/12 - 01 - 12 - 13:52 
 * @Description: com.whj.apidriver.controller
 */

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PutMapping("/user")
    public ResponseResult updateUser(@RequestBody DriverUser driverUser){
        return userService.updateUser(driverUser);
    }

    /**
     * 司机修改自身状态
     *
     * @param driverUserWorkStatus
     * @return
     */
    @PostMapping("/driver-user-work-status")
    public ResponseResult changeWorkStatus(@RequestBody DriverUserWorkStatus driverUserWorkStatus){
        return userService.changeWorkStatus(driverUserWorkStatus);
    }

    /**
     * 根据司机id寻找车辆信息
     *
     * @param driverPhone
     * @return
     */
    @GetMapping("/driver-car-binding-relationship")
    public ResponseResult<DriverCarBindingRelationship> findMessage(@RequestParam String driverPhone){
        return userService.findMessage(driverPhone);
    }

    @GetMapping("/work-status")
    public ResponseResult<DriverUserWorkStatus> getWorkStatus(Long driverId){
        return userService.getWorkStatus(driverId);
    }
}
